<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>微商管理 － 添加新商品</title>
    <meta name="keywords" content="龙蛙商城">
    <meta name="description" content="龙蛙商城">

    <link rel="shortcut icon" href="/favicon.ico">
    <link href="../../web/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="../../web/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="/web/css/plugins/toastr/toastr.min.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="row">
        <div class="col-md-12">
            <div class="ibox">
                <div class="ibox-content">
                    <form id="ajaxExFrom" class="form-horizontal" role="form">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">预警值：</label>
                            <div class="col-sm-8">
                                <input type="number" required id="warning_val" name="warning_val"/>
                            </div>
                            <div class="col-sm-2"></div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-5"></div>
                            <button type="button" id="submitWarningCreate" class="btn btn-primary col-sm-2">保存</button>
                            <div class="col-sm-5"></div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../../web/js/jquery.min.js?v=2.1.4"></script>
<script src="../../web/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/web/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/web/js/plugins/validate/messages_zh.min.js"></script>
<script src="/web/js/plugins/toastr/toastr.min.js"></script>
<script src="/web/js/self/commons.js"></script>
<script type="text/javascript">
    $.validator.setDefaults({
        highlight: function (e) {
            $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
        }, success: function (e) {
            e.closest(".form-group").removeClass("has-error").addClass("has-success");
        }, errorElement: "span", errorPlacement: function (e, r) {
            e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
        }, errorClass: "help-block m-b-none", validClass: "help-block m-b-none"
    });
    $("#submitWarningCreate").click(function () {
        $("#ajaxExFrom").validate();
        if ($("input[id=warning_val]").val() === ""){
            toastr.warning("请输入预警值", "警告");
            return false;
        }
        if (Number($("input[id=warning_val]").val()) < 0){
            toastr.warning("预警值不能小于0", "警告");
            return false;
        }
        $.ajax({
            url: "/goods/update/setUpWarning",
            type: "GET",
            data: {val: $("input[id=warning_val]").val()},
            dataType: "json",
            async: false,
            success: function (data, textStatus, jqXHR) {
                console.log("xxxxx")
                toastr.success(data.msg, data.title);
            },
            error: function (jqXHR, textStatus, errorThrown) {
                toastr.error(errorThrown, textStatus);
            }
        });
    });
</script>
</body>
</html>
